package com.blkkj.huan.Controller;

import com.aliyuncs.iot.model.v20170420.UpdateProductRequest;
import com.aliyuncs.iot.model.v20170420.UpdateProductResponse;
import com.blkkj.huan.util.BaseTest;
import com.blkkj.huan.util.LogUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class updateProductController extends BaseTest {

    @GetMapping("/updateProduct")
    public String updateProduct(){
        //修改产品信息
        updateProductTest("nUg7byNAibq", "heihei", null);
        return "huan";
    }

    /**
     * 修改产品
     *
     * @param productKey 产品PK 必需
     * @param productName 产品名称 非必需
     * @param productDesc 产品描述 非必需
     */
    public static void updateProductTest(String productKey, String productName, String productDesc) {
        UpdateProductRequest request = new UpdateProductRequest();
        request.setProductKey(productKey);
        request.setProductName(productName);
        request.setProductDesc(productDesc);
        UpdateProductResponse response = (UpdateProductResponse)executeTest(request);
        if (response != null && response.getSuccess() != false) {
            LogUtil.print("修改产品成功！");
        } else {
            LogUtil.error("修改产品失败！requestId:" + response.getRequestId() + "原因:" + response.getErrorMessage());
        }

    }
}
